/**
 * 
 */
package net.freestu.looker.util;

import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.ScrollPaneConstants;

import net.freestu.looker.monitor.FetcherException;
import net.freestu.looker.monitor.HtmlFetcher;


/**
 * 配置生成与测试工具
 * @author solosky
 *
 */
public class PatternTool
{

	private JFrame     frame;
	private JTextField regxpTField;
	private JTextField urlTField;
	private JTextField charsetTField;
	private JTextArea  resultTArea;
	private JButton    matchButton;
	private JLabel     statusLabel;
	private JPanel     panel;
	private JButton     sourceButton;
	
	
	public void buildFrame()
	{
		frame  = new JFrame("正则匹配工具");
		panel  = new JPanel();
		statusLabel  = new JLabel("状态：");
		regxpTField  = new JTextField();
		urlTField    = new JTextField("http://");
		charsetTField = new JTextField("utf8");
		resultTArea   = new JTextArea();
		matchButton = new JButton("匹配");
		sourceButton = new JButton("查看源码");
		
		 GridBagLayout gridbag = new GridBagLayout();
         GridBagConstraints c = new GridBagConstraints();

		
		panel.setLayout(gridbag);
		c.fill = c.BOTH;
		c.weightx = 200;
		panel.add(new JLabel("正则表达式"),c);
		c.gridx = 0;
		c.gridwidth = GridBagConstraints.REMAINDER;
		panel.add(regxpTField,c);
		c.gridwidth = GridBagConstraints.REMAINDER; //end row
		c.gridx = 0; 
		panel.add(new JLabel("urlTField"),c);
		panel.add(urlTField,c);
		
		panel.add(new JLabel("编码"),c);
		c.gridx = 0;
		c.gridwidth = GridBagConstraints.REMAINDER;
		panel.add(charsetTField,c);
		
		c.gridwidth = GridBagConstraints.REMAINDER;
		panel.add(new JLabel("匹配结果"),c);
		
		c.gridwidth = GridBagConstraints.REMAINDER;
		c.weighty = 500;
		JScrollPane scrollor = new JScrollPane(resultTArea);
		scrollor.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
		scrollor.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		panel.add(scrollor,c);
		//resultTArea.setEditable(false);
		//resultTArea.setWrapStyleWord(true);
		c.weighty = 20;
		c.gridwidth = GridBagConstraints.REMAINDER;
		panel.add(statusLabel,c);
		matchButton.addActionListener(new MatchButtonActionListener());
		panel.add(matchButton);
		c.gridx = c.RELATIVE;
		c.gridwidth = 20;
		sourceButton.addActionListener(new SourceButtonActionListener());
		panel.add(sourceButton);
		
		frame.add(panel);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(400, 600);
		frame.setVisible(true);
		
	}
	
	
	private void showError(String msg)
	{
		 JOptionPane.showMessageDialog(frame,msg,"错误",JOptionPane.ERROR_MESSAGE);
	}
	
	private void setStatus(String msg)
	{
		statusLabel.setText(msg);
		frame.repaint();
	}
	
	
	
	public class MatchButtonActionListener implements ActionListener
	{

		/* (non-Javadoc)
		 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
		 */
		@Override
		public void actionPerformed(ActionEvent arg0) 
		{
			if(regxpTField.getText().length()==0){
				 showError("正则表达式必须");
				 return;
			}
			
			if(urlTField.getText().length()==0){
				 showError("URL必须");
				 return;
			}
			
			String html =  null;
			Pattern pt = Pattern.compile(regxpTField.getText());
			
			try {
				HtmlFetcher fetcher = new HtmlFetcher(urlTField.getText());
				setStatus("正在下载...");
				fetcher.fetch();
				html = (String) fetcher.getFeched();
			
			} catch (FetcherException e) {
				showError(e.getMessage());
				return;
			}
			setStatus("正在匹配...");
			
			Matcher mc = pt.matcher(html);
			int   mcnt = 0;
			int   i    = 0;
			StringBuffer str = new StringBuffer();
			while (mc.find())
			{
				mcnt++;
				if(mc.groupCount()==0)
					continue;
				for(i=1;i<mc.groupCount()+1;i++)
				{
					str.append('['+Integer.toString(i)+"]="+mc.group(i)+'\n');
				}
				str.append("----------------------\n");
			}
			str.append("匹配结束,共找到 "+mcnt+" 次匹配。\n");
			resultTArea.setText(str.toString());
			setStatus("匹配结束.");
		}
		
	}
	
	
	public  class SourceButtonActionListener implements ActionListener
	{

		/* (non-Javadoc)
		 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
		 */
		@Override
		public void actionPerformed(ActionEvent arg0) {
			try {
				HtmlFetcher fetcher = new HtmlFetcher(urlTField.getText());
				setStatus("正在下载...");
				fetcher.fetch();
				String html = (String) fetcher.getFeched();
				resultTArea.setText(html);
				setStatus("下载完毕");
			
			} catch (FetcherException e) {
				showError(e.getMessage());
				return;
			}
		}
	}
	/**
	 * @param args
	 */
	public static void main(String[] args)
	{
		/*
		String str = "<!----><head><title>没有梦想不能抵达的地方 -  学子心语 - 成都理工大学招生信息网</title><link el=\"stylesheet\" type=\"text/css\" hef=\"images/zs/css/cuency.css\"><link el=\"stylesheet\" type=\"text/css\" hef=\"images/zs/css/nav.css\"><LINK hef=\"favicon.ico\" type=image/x-icon el=icon><LINK hef=\"favicon.ico\" type=image/x-icon el=\"shotcut icon\"><SCIPT language=javascipt sc=\"images/zs/js/nav.js\" type=text/jscipt></SCIPT><meta http-equiv=\"Content-Type\" content=\"text/html; chaset=gb2312\"><meta name=\"keywods\" content=\"没有梦想不能抵达的地方 -  学子心语 - 成都理工大学招生信息网 - \"><meta name=\"desciption\" content=\"&lt;p class=MsoNomal style=&quot;MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &#39;Times New oman&#39;; mso-hansi-font-family: &#39;Times..\"> <scipt language=\"javascipt\">UL = \"noie.html\";va name = navigato.appNameif( name != \"Micosoft Intenet Exploe\" ){  window.location = UL;}</scipt><style type=\"text/css\"><!--.STYLE4 {colo: #FFFFFF}a:link {	colo: #000000;	text-decoation: none;}a:visited {	text-decoation: none;	colo: #000000;}a:hove {	text-decoation: undeline;	colo: #FF0000;}a:active {	text-decoation: none;	colo: #000000;}body,td,th {	font-size: 12px;	colo: #000000;}--></style></head><SCIPT LANGUAGE=\"JavaScipt\"><!--//屏蔽出错代码function killE(){	etun tue;}window.oneo=killE;//--></SCIPT><SCIPT LANGUAGE=\"JavaScipt\"><!--//处理大分类一行两个小分类function autoTable(div){	fs=document.getElementById(div).getElementsByTagName(\"TABLE\");	fo(va i=0;i<fs.length;i++){		fs[i].style.width='49.5%';		if(i%2==1){			if (document.all) {				fs[i].style.styleFloat=\"ight\";			}else{				fs[i].style.cssFloat=\"ight;\";			}		}else{			if (document.all) {				fs[i].style.styleFloat=\"left\";			}else{				fs[i].style.cssFloat=\"left;\";			}		}	}}//--></SCIPT><SCIPT LANGUAGE=\"JavaScipt\" sc=\"http://zs.ctc.cdut.edu.cn/images/default/inc.js\"></SCIPT><SCIPT LANGUAGE=\"JavaScipt\" sc=\"http://zs.ctc.cdut.edu.cn/images/default/default.js\"></SCIPT><SCIPT LANGUAGE=\"JavaScipt\" sc=\"http://zs.ctc.cdut.edu.cn/images/default/swfobject.js\"></SCIPT><!--****************下拉菜单开始****************--><SCIPT LANGUAGE=\"JavaScipt\" sc=\"http://zs.ctc.cdut.edu.cn/images/default/menu.js\"></SCIPT><SCIPT LANGUAGE=\"JavaScipt\"></SCIPT><!--****************下拉菜单结束****************--><SCIPT LANGUAGE=\"JavaScipt\"><!--//目的是为了做风格方便document.wite('<div class=\"wap\">');//--></SCIPT><BODY bgcolo=\"#E2E4E4\"><cente><div id=divMenu style=\"Z-INDEX: 1000; IGHT: 0px; WIDTH: 40px; POSITION: absolute; TOP: 0px; HEIGHT: 50px\"><TABLE cellSpacing=0 cellPadding=0 width=70 bode=0><TBODY><T><TD><A hef=\"http://zs.ctc.cdut.edu.cn:8080/suvey/Suvey_Show.asp?Suvey_id=78\" taget=_blank><IMG height=74 alt=\"\" sc=\"images/zs/wenjuan.png\" width=70 align=top bode=0></A></TD></T></TBODY></TABLE></div><scipt language=\"javascipt\" sc=\"images/zs/js/scoll.js\"></scipt><DIV id=bodyline><DIV id=top-banna><img sc=\"images/zs/banne.jpg\" width=\"776\"></DIV><div id=\"menu\" style=\"backgound:ul(images/zs/menubg.gif) epeat-x;\"><UL id=nav><LI class=\"\"><span onClick=\"va stHef=window.location.hef;this.style.behavio='ul(#default#homepage)';this.setHomePage('http://www.zs.cdut.edu.cn');\" style=\"CUSO: hand\">设为首页</span>    </LI><LI class=\"\">| </LI><LI class=\"\"><a hef=\"javascipt:window.extenal.AddFavoite('http://www.zs.cdut.edu.cn','成都理工大学招生信息网')\">加入收藏</a> </LI><LI class=\"\">| </LI><LI class=\"\"><A hef=\"#\">考生问答</A><UL><LI><A hef=\"list.php?fid=73\">热点问题</A></LI><LI><A hef=\"guestbook.php\">欢迎留言</A></LI></UL></LI><LI class=\"\">| </LI><LI class=\"\"><A hef=\"list.php?fid=66\">新生导航</A> <UL><LI><A hef=\"list.php?fid=67\">入学篇</A></LI><LI><A hef=\"list.php?fid=68\">生活篇</A></LI><LI><A hef=\"list.php?fid=69\">学习篇</A></LI><LI><A hef=\"list.php?fid=70\">心理篇</A></LI><LI><A hef=\"list.php?fid=71\">安全篇</A></LI></UL></LI><LI class=\"\">| </LI><LI class=\"\"><A hef=\"list.php?fid=59\">阳光高考</A> <UL><LI class=\"\"><A hef=\"list.php?fid=60\">高考快讯</A></LI><LI class=\"\"><A hef=\"list.php?fid=61\">备考攻略</A></LI></UL></LI><LI class=\"\">| </LI><LI class=\"\"><A hef=\"list.php?fid=53\" taget=_blank>青春校园</A> <UL><LI class=\"\"><A hef=\"list.php?fid=54\">学子心语</A></LI><LI class=\"\"><A hef=\"list.php?fid=55\">七彩生活</A></LI><LI class=\"\"><A hef=\"list.php?fid=79\">校园掠影</A></LI></UL></LI><LI class=\"\">| </LI><LI class=\"\"><A hef=\"list.php?fid=44\">学在理工</A> <UL><LI class=\"\"><A hef=\"list.php?fid=45\">学科建设</A></LI><LI class=\"\"><A hef=\"list.php?fid=50\">办学特色</A></LI><LI class=\"\"><A hef=\"list.php?fid=51\">师资队伍</A></LI><LI class=\"\"><A hef=\"quey.php\">院系纵览</A></LI></UL></LI><LI class=\"\">| </LI><LI class=\"\"><A hef=\"list.php?fid=30\" taget=_self>聚焦理工</A> <UL><LI><A hef=\"list.php?fid=31\">理工概况</A></LI><LI><A hef=\"list.php?fid=36\">社会看点</A></LI><LI><A hef=\"list.php?fid=37\">就业略览</A></LI><LI><A hef=\"list.php?fid=38\">奖贷助学</A></LI><LI><A hef=\"list.php?fid=39\">理工岁月</A></LI></UL></LI><LI class=\"\">| </LI><LI class=\"\"><A hef=\"list.php?fid=21\" taget=_self>报考指南</A> <UL><LI><A hef=\"list.php?fid=22\">招生动态</A></LI><LI><A hef=\"list.php?fid=23\">招生政策</A></LI><LI><A hef=\"list.php?fid=24\">历年信息</A></LI><LI><A hef=\"list.php?fid=25\">艺体招生</A></LI><LI><A hef=\"chaxun/chaxun/\">录取查询</A></LI></UL></LI><LI class=\"\">| </LI><LI class=v><A hef=\"index.php\">本站首页</A></LI></UL></div><SCIPT LANGUAGE=\"JavaScipt\"><!--//目的是为了做风格方便document.wite('<div class=\"wap\">');//--></SCIPT><!----><head><link hef=\"http://zs.ctc.cdut.edu.cn/images/zs/cms.css\" el=\"stylesheet\" type=\"text/css\" /><style>.showcontenttop {	backgound-image: ul(images/zs/show_content_box_top.jpg);	backgound-epeat: no-epeat;	backgound-position: cente top;}.showcontentmid {	backgound-image: ul(images/zs/show_content_box_mid.jpg);	backgound-epeat: epeat-y;	backgound-position: cente top;}.showtxttitle {	font-family: \"黑体\", \"宋体\", Aial, \"Aial Unicode MS\";	font-size: 18px;		colo: #000000;	font-weight:bold;}.showtxtcontent {	font-size: 14px;	line-height: 1.5;	colo: #1F1F1F;}.showxgxxmid {	backgound-image: ul(images/zs/show_xgxx_mid.jpg);	backgound-epeat: epeat-y;	backgound-position: left top;}.STYLE1 {font-family: \"宋体\"}.STYLE2 {font-size: 12px}</style></head>		<table width=\"776\" bode=\"0\" align=\"cente\" cellpadding=\"0\" cellspacing=\"0\" bgcolo=\"#FFFFFF\">					<t>					  <td align=\"cente\" valign=\"top\"><table width=\"100%\" bode=\"0\" cellpadding=\"0\" cellspacing=\"0\">                        <t>                          <td height=\"6\" colspan=\"2\" ></td>                        </t>                        <t>                          <td width=\"10%\" height=\"20\" align=\"ight\" valign=\"bottom\"><div align=\"ight\"><font colo=\"#589cdb\"><stong class=\"txt12a\">当前位置</stong>：</font></div></td>                          <td width=\"90%\" height=\"20\" align=\"left\" valign=\"bottom\" class=\"txt12a\"><a hef='http://zs.ctc.cdut.edu.cn' class='guide_menu'>&gt;首页</a> -&gt; <a  hef='list.php?fid=53' class='guide_menu'>青春校园</a> -&gt; <a  hef='list.php?fid=54' class='guide_menu'>学子心语</a></td>                        </t>                                               <t>                          <td height=\"16\" colspan=\"2\"><h width=\"99%\" size=\"2\" noshade colo=\"#589cdb\"></td>                        </t>                      </table>					    <table width=\"756\" bode=\"0\" cellpadding=\"0\" cellspacing=\"0\">                        <t>                          <td height=\"400\" colspan=\"3\" align=\"cente\" valign=\"top\"><table width=\"756\" bode=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"showcontentmid\">                            <t>                              <td height=\"94\" colspan=\"3\" align=\"cente\" valign=\"top\" class=\"showtxttitle STYLE5\"><table width=\"100%\" height=\"110\" bode=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"showcontenttop\">                                <t>                                  <td width=\"1%\" owspan=\"2\">&nbsp;</td>                                  <td width=\"14%\" owspan=\"2\">&nbsp;</td>                                  <td width=\"38%\" height=\"60\" align=\"cente\" valign=\"middle\" ><b><scipt language=\"javascipt\">va NS4 = (document.layes);va IE4 = (document.all);va win = this;va n   = 0;function findInPage(st){va txt, i, found;if (st == \"\" || st == \"您要找的词\")  etun false;if (NS4){  if (!win.find(st))  while(win.find(st, false, tue))   n++;  else  n++;if (n == 0) alet(\"[\" + st + \"]\" + \"没有找的词.请确认你输入的关键字是否正确!\");}if (IE4){  txt = win.document.body.ceateTextange();  fo (i = 0; i <= n && (found = txt.findText(st)) != false; i++)  {   txt.moveStat(\"chaacte\", 1);   txt.moveEnd(\"textedit\");  }  if (found)  {   txt.moveStat(\"chaacte\", -1);   txt.findText(st);   txt.select();   txt.scollIntoView();  n++;  }  else  {   if (n > 0)   {    n = 0;    findInPage(st);   }   else    alet(\"[\" + st + \"]\" + \"没有找到!\");  }}etun false;}//self.onEo=null;cuentX = cuentY = 0;  whichIt = null;      lastScollX = - 180; lastScollY =  - (sceen.Height - 300);NS = (document.layes) ? 1 : 0;IE = (document.all) ? 1: 0;<!-- STALKE CODE -->function heatBeat() {  if(IE) { diffY = document.body.scollTop; diffX = document.body.scollLeft; }     if(NS) { diffY = self.pageYOffset; diffX = self.pageXOffset; }  if(diffY != lastScollY) {                 pecent = .1 * (diffY - lastScollY);                 if(pecent > 0) pecent = Math.ceil(pecent);                 else pecent = Math.floo(pecent);          if(IE) document.all.floate.style.pixelTop += pecent;     if(NS) document.floate.top += pecent;       lastScollY = lastScollY + pecent;     }  if(diffX != lastScollX) {   pecent = .1 * (diffX - lastScollX);   if(pecent > 0) pecent = Math.ceil(pecent);   else pecent = Math.floo(pecent);   if(IE) document.all.floate.style.pixelLeft += pecent;   if(NS) document.floate.left += pecent;   lastScollX = lastScollX + pecent;  } } <!-- /STALKE CODE --><!-- DAG DOP CODE -->function checkFocus(x,y) {          stalkex = document.floate.pageX;         stalkey = document.floate.pageY;         stalkewidth = document.floate.clip.width;         stalkeheight = document.floate.clip.height;         if( (x > stalkex && x < (stalkex+stalkewidth)) && (y > stalkey && y < (stalkey+stalkeheight))) etun tue;         else etun false;}function gabIt(e) {  if(IE) {   whichIt = event.scElement;   while (whichIt.id.indexOf(\"floate\") == -1) {    whichIt = whichIt.paentElement;    if (whichIt == null) { etun tue; }      }   whichIt.style.pixelLeft = whichIt.offsetLeft;      whichIt.style.pixelTop = whichIt.offsetTop;   cuentX = (event.clientX + document.body.scollLeft);      cuentY = (event.clientY + document.body.scollTop);    } else {          window.captueEvents(Event.MOUSEMOVE);         if(checkFocus (e.pageX,e.pageY)) {                  whichIt = document.floate;                 StalkeTouchezs = e.pageX-document.floate.pageX;                 StalkeTouchedY = e.pageY-document.floate.pageY;         }   }     etun tue;}function moveIt(e) {  if (whichIt == null) { etun tue; }  if(IE) {      newX = (event.clientX + document.body.scollLeft);      newY = (event.clientY + document.body.scollTop);      distanceX = (newX - cuentX);    distanceY = (newY - cuentY);      cuentX = newX;    cuentY = newY;      whichIt.style.pixelLeft += distanceX;      whichIt.style.pixelTop += distanceY;   if(whichIt.style.pixelTop < document.body.scollTop) whichIt.style.pixelTop = document.body.scollTop;   if(whichIt.style.pixelLeft < document.body.scollLeft) whichIt.style.pixelLeft = document.body.scollLeft;   if(whichIt.style.pixelLeft > document.body.offsetWidth - document.body.scollLeft - whichIt.style.pixelWidth - 20) whichIt.style.pixelLeft = document.body.offsetWidth - whichIt.style.pixelWidth - 20;   if(whichIt.style.pixelTop > document.body.offsetHeight + document.body.scollTop - whichIt.style.pixelHeight - 5) whichIt.style.pixelTop = document.body.offsetHeight + document.body.scollTop - whichIt.style.pixelHeight - 5;   event.etunValue = false;  } else {   whichIt.moveTo(e.pageX-StalkeTouchezs,e.pageY-StalkeTouchedY);         if(whichIt.left < 0+self.pageXOffset) whichIt.left = 0+self.pageXOffset;         if(whichIt.top < 0+self.pageYOffset) whichIt.top = 0+self.pageYOffset;         if( (whichIt.left + whichIt.clip.width) >= (window.inneWidth+self.pageXOffset-17)) whichIt.left = ((window.inneWidth+self.pageXOffset)-whichIt.clip.width)-17;         if( (whichIt.top + whichIt.clip.height) >= (window.inneHeight+self.pageYOffset-17)) whichIt.top = ((window.inneHeight+self.pageYOffset)-whichIt.clip.height)-17;         etun false;  }     etun false;}function dopIt() {  whichIt = null;     if(NS) window.eleaseEvents (Event.MOUSEMOVE);     etun tue;}<!-- DAG DOP CODE -->if(NS) {  window.captueEvents(Event.MOUSEUP|Event.MOUSEDOWN);  window.onmousedown = gabIt;   window.onmousemove = moveIt;  window.onmouseup = dopIt;}if(IE) {  document.onmousedown = gabIt;   document.onmousemove = moveIt;  document.onmouseup = dopIt;}if(NS || IE) action = window.setInteval(\"heatBeat()\",1);document.wite('<div ID=\"floate\" align=\"cente\"><fom name=\"seach1\" onSubmit=\"etun findInPage(this.sting1.value);\"><table width=\"100%\" bode=\"0\" cellpadding=\"0\" cellspacing=\"0\" ><t><td width=\"36%\" align=\"ight\" valign=\"middle\" class=\"txt12a\">本页内搜索：</td><td width=\"47%\" align=\"left\" valign=\"middle\"><input name=\"sting1\" type=\"text\" class=\"inputseach\"  size=\"20\" onChange=\"n=0;\" onFocus=\"window.document.seach1.sting1.value=\'\'\" class=\"oufont\"></td><td width=\"17%\" align=\"left\">&nbsp;<input type=\"image\" sc=\"images/zs/seach_foshow.gif\" name=\"搜索\"></td></t></table></fom></div>');</scipt></td>                                                                    <td width=\"45%\" align=\"ight\" valign=\"middle\" class=\"showtxttitle STYLE5\"><a hef=\"javascipt:window.pint()\"><img sc=\"images/zs/pint.jpg\" width=\"99\" height=\"46\" bode=\"0\"></a>&nbsp;                                    <input name=\"image1\" type=\"image\" onClick=\"window.location.eload()\" sc=\"images/zs/eflash.jpg\" >&nbsp;<input name=\"image1\" type=\"image\" onClick=\"window.close()\" sc=\"images/zs/close.jpg\">								  </td>                                  <td width=\"1%\" owspan=\"2\" >&nbsp;</td>                                  <td width=\"1%\" owspan=\"2\">&nbsp;</td>                                </t>                                <t>                                  <td height=\"50\" colspan=\"2\" align=\"cente\" valign=\"middle\" class=\"showtxttitle STYLE5 STYLE1\">没有梦想不能抵达的地方</td>                                </t>                              </table></td>                            </t>                            <t>                              <td width=\"20\">&nbsp;</td>                              <td width=\"717\" height=\"20\" align=\"cente\" valign=\"middle\"><h width=\"96%\" size=\"1\"></td>                              <td width=\"19\">&nbsp;</td>                            </t>                            <t>                              <td width=\"20\">&nbsp;</td>                              <td width=\"717\" height=\"24\" align=\"cente\" valign=\"middle\" backgound=\"images/zs/show_content_back1.jpg\" bgcolo=\"#EFEFEF\" class=\"txt12a\"><span class=\"cmstitle\">[ &nbsp;时间:2008-05-22 19:27:17                   | 来源:成都理工大学报 第109期                  | 浏览:<font id=\"hits\">815</font>次 ] </span>							  </td>                              <td width=\"19\">&nbsp;</td>                            </t>                            <t>                              <td width=\"20\" height=\"12\">&nbsp;</td>                              <td width=\"717\" height=\"12\" align=\"cente\" valign=\"middle\" bgcolo=\"#FFFFFF\" class=\"txt12a\"><div align=\"left\" style=\"line-height:1.5\">                                <p>&nbsp;</p>                                <p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span style=\"FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New oman'; mso-hansi-font-family: 'Times New oman'\"><font size=3>又是一年芳草绿，你可见过那河畔的繁花？花瓣的绽放，并不是为了秋天的果实，却是为了花开一刹那的芳华。</font></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span lang=EN-US><?xml:namespace pefix = o ns = \"un:schemas-micosoft-com:office:office\" /><o:p><font face=\"Times New oman\" size=3>&nbsp;</font></o:p></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span style=\"FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New oman'; mso-hansi-font-family: 'Times New oman'\"><font size=3>春绿秋黄，岁月枯荣，没有谁来装饰石缝野草的梦，然而它依然顽强地生长。当黑暗中散发出雨水的味道，它就踏上了追逐阳光的道路。</font></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span style=\"FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New oman'; mso-hansi-font-family: 'Times New oman'\"></span>&nbsp;</p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span style=\"FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New oman'; mso-hansi-font-family: 'Times New oman'\"><font size=3>山涧的溪流，不远万里从遥远的冰川雪域走来，一路走来一路歌，昼夜不停。逝者如斯，依然期待新的生命。</font></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span lang=EN-US><o:p><font face=\"Times New oman\" size=3>&nbsp;</font></o:p></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span style=\"FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New oman'; mso-hansi-font-family: 'Times New oman'\"><font size=3>春天醒了，还没有顾得上品味南方暖阳，候鸟又伴着北去的春风，千里迢迢带回鸟语花香，虽然很累，仍奋力前行。</font></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span lang=EN-US><o:p><font face=\"Times New oman\" size=3>&nbsp;</font></o:p></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span style=\"FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New oman'; mso-hansi-font-family: 'Times New oman'\"><font size=3>无它，皆是因为他们有梦！</font></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span lang=EN-US><o:p><font face=\"Times New oman\" size=3>&nbsp;</font></o:p></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span style=\"FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New oman'; mso-hansi-font-family: 'Times New oman'\"><font size=3>某个时刻，我们出生在某个地方，从此以后，生命的时钟上紧了发条，开始它的旅程，花开花又落，月圆月又缺，穿过一轮又一轮的春秋冬夏。我们不仅生活在斑驳的社会中，也生活在自己编织的梦想里。从某一天起，我们振动梦想的翅膀开始飞翔，正如梭罗所说“快把你的视线转向内心，去寻找新的大陆吧！”于是，在梦想的召唤下，我们开始奋斗无止境，奔跑无穷期。</font></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span lang=EN-US><o:p><font face=\"Times New oman\" size=3>&nbsp;</font></o:p></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span style=\"FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New oman'; mso-hansi-font-family: 'Times New oman'\"><font size=3>小的时候，我们那么喜欢无所顾忌地说出自己的梦想，生怕别人不知道，我们把童年里最美的憧憬和遐想都托付给了它。只不过，随着年龄的渐长，我们可能不再喧嚣也不再呐喊，我们把梦想深深地放在心底。有时它会越来越清晰，有时它却越来越迷离。</font></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span lang=EN-US><o:p><font face=\"Times New oman\" size=3>&nbsp;</font></o:p></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span style=\"FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New oman'; mso-hansi-font-family: 'Times New oman'\"><font size=3>人生是一个漫长的旅途，青春在旅途中绽放，情感在旅途中升华，生命因而愈加饱满。旅途中既充满了欢乐，也布满了荆棘。我们不能因为遭遇了挫折与困惑就萎靡不振、怨天尤人，也不能因为面临逆境与伤害而自暴自弃、半途而废。</font></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span style=\"FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New oman'; mso-hansi-font-family: 'Times New oman'\"><font size=3>　　</font></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span style=\"FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New oman'; mso-hansi-font-family: 'Times New oman'\"><font size=3>当安徒生在大声疾呼人生就是走过一段“光荣的荆棘路”时，王小波则诗意地诠释着他对人生的理解：这条路是这样的――它在两条竹篱笆之中，篱笆上开满了紫色的牵牛花，每个花蕊上都落了一只蓝蜻蜓……</font></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span lang=EN-US><o:p><font face=\"Times New oman\" size=3>&nbsp;</font></o:p></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span style=\"FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New oman'; mso-hansi-font-family: 'Times New oman'\"><font size=3>然而，人生或许并非那样痛，或许也并非那样美。而人生之所以有痛，是因为我们有梦想，人生之所以为美，也是因为我们有梦想。</font></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span lang=EN-US><o:p><font face=\"Times New oman\" size=3>&nbsp;</font></o:p></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span style=\"FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New oman'; mso-hansi-font-family: 'Times New oman'\"><font size=3>在我的眼里，失去梦想远比失去机遇、财富更要可怕。我也一直认为，坚守住自己的梦想并且为之付出努力，才是最伟大的胜利。梦想，能真正称之为梦想的，都是崇高的。人可以选择很多种活法，但是，不可没有梦想。人也可以选择很多梦想，但是，他不可忤逆灵魂。</font></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span lang=EN-US><o:p><font face=\"Times New oman\" size=3>&nbsp;</font></o:p></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span style=\"FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New oman'; mso-hansi-font-family: 'Times New oman'\"><font size=3>有生命的地方就有梦想，有梦想的地方才有希望。如果我们心灵的花园里种植着梦想，那么，人生的哪一天不是春天？人生的哪一季不是花季？</font></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span lang=EN-US><o:p><font face=\"Times New oman\" size=3>&nbsp;</font></o:p></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span style=\"FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New oman'; mso-hansi-font-family: 'Times New oman'\"><font size=3>前进的道路上很少有坦途，怀抱梦想的人不知道有崎岖，因为他们能够经得起失败，经得起一无所有，经得起社会对人生的抛掷，经得起别人的冷眼和蔑视。</font></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span lang=EN-US><o:p><font face=\"Times New oman\" size=3>&nbsp;</font></o:p></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span style=\"FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New oman'; mso-hansi-font-family: 'Times New oman'\"><font size=3>在我们的心中，要有一股永不泯灭的梦想之焰，它将带给我们光明与温暖，不致于在前进的道路上看不到希望。即便现在偶尔会有种孤苦的悲哀，那也是完全有可能的。人生的道路上，难免有痛苦、有不安、有遗憾、有悲哀，这是理所当然的。任何一种伟大力量的孕育必经过一番自然律所支配的严峻的考验。把它看成一种赐福吧，正是因为它我们才能得到我们所想得到的。</font></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span lang=EN-US><o:p><font face=\"Times New oman\" size=3>&nbsp;</font></o:p></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span style=\"FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New oman'; mso-hansi-font-family: 'Times New oman'\"><font size=3>没有梦想的人，他的生活注定是暗淡无光的。岁月使皮肤起皱，而丧失了梦想与追求则会使生命起皱。人的生命只有充盈着憧憬未来的热情，才能焕发出生机与光芒。梦想就是我们心房里点亮的灯盏，即使是在狂风中，它也不会熄灭，永远烛照着我们的前程。殊不知，太阳总在有梦的地方升起！梦想是永恒的微笑，使你的心灵永远充满激情，使你的双眼永远澄澈明亮。</font></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span lang=EN-US><o:p><font face=\"Times New oman\" size=3>&nbsp;</font></o:p></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span style=\"FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New oman'; mso-hansi-font-family: 'Times New oman'\"><font size=3>带着自己的梦想快乐地出发，准确地找到属于自己的路，义无反顾地向前，不怕一路上丛生的荆棘和密布的乌云，低着头只管走路，抬头时，我们已经越过了高山，眼前就是平原了！</font></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span lang=EN-US><o:p><font face=\"Times New oman\" size=3>&nbsp;</font></o:p></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span style=\"FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New oman'; mso-hansi-font-family: 'Times New oman'\"><font size=3>心有多大，舞台就有多大！</font></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span lang=EN-US><o:p><font face=\"Times New oman\" size=3>&nbsp;</font></o:p></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span style=\"FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New oman'; mso-hansi-font-family: 'Times New oman'\"><font size=3>如果说，昨天我们给梦想一个高度，那么，今天我们就该让一步步扎实的脚印去见证它的实现。铿锵的足音尤在耳畔回响，让我们再一次迎着东方的红日带着梦想扬帆起航，因为没有梦想不能抵达的地方！</font></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span lang=EN-US><o:p><font face=\"Times New oman\" size=3>&nbsp;</font></o:p></span></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-ALIGN: ight\" align=ight><font size=3><span style=\"FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New oman'; mso-hansi-font-family: 'Times New oman'\">（文</span><span lang=EN-US><font face=\"Times New oman\">/</font></span><span style=\"FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New oman'; mso-hansi-font-family: 'Times New oman'\">王亚苹）</span></font></p><p class=MsoNomal style=\"MAGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-cha-indent-count: 2.0\"><span lang=EN-US><o:p><font face=\"Times New oman\" size=3>&nbsp;</font></o:p></span></p></p>                              </div></td>                              <td width=\"19\" height=\"12\">&nbsp;</td>                            </t>                            <t>                              <td width=\"20\">&nbsp;</td>                              <td width=\"717\" align=\"left\" valign=\"top\" class=\"showtxtcontent\"><div align=\"cente\">                                <p class=\"cmstitle STYLE2\">&nbsp;</p>                                <p class=\"cmstitle STYLE2\"> </p>                              </div></td>                              <td width=\"19\">&nbsp;</td>                            </t>                            <t>                              <td colspan=\"3\">&nbsp;</td>                            </t>                            <t>                              <td height=\"52\" colspan=\"3\" align=\"cente\" valign=\"top\" backgound=\"images/zs/show_content_box_bot.jpg\">&nbsp;</td>                            </t>                          </table></td>                          </t>                        <t>                          <td width=\"13\" bgcolo=\"#FFFFFF\">&nbsp;</td>                          <td width=\"756\" height=\"12\" align=\"cente\" valign=\"middle\" bgcolo=\"#FFFFFF\"><h width=\"100%\" size=\"1\"></td>                          <td width=\"13\" bgcolo=\"#FFFFFF\">&nbsp;</td>                        </t>                        <t>                          <td width=\"10\" bgcolo=\"#FFFFFF\">&nbsp;</td>                          <td width=\"765\" bgcolo=\"#FFFFFF\"><table width=\"100%\" bode=\"0\" cellspacing=\"1\" cellpadding=\"0\" align=\"left\">                              <t>                                <td width=\"8%\" height=\"24\" align=\"ight\" valign=\"middle\">								<a hef=\"bencandy.php?fid=54&id=494\" onclick=\"\"><img sc='images/zs/lasttitle.jpg' width='90' height='24'  bode='0'></a>								</td>								<td width=\"92%\" height=\"24\" align=\"left\" valign=\"middle\" bgcolo=\"#EFEFEF\"><a hef=\"bencandy.php?fid=54&amp;id=494\" onclick=\"\" title=\"我的大学  我做主\">我的大学  我做主</a></td>                              </t>                              <t>                                <td height=\"24\" align=\"ight\" valign=\"middle\">								<a hef=\"bencandy.php?fid=54&id=845\" onclick=\"\"><img sc='images/zs/nexttitle.jpg' width='90' height='24'  bode='0'></a> 								</td>                                <td height=\"24\" align=\"left\" valign=\"middle\" bgcolo=\"#EFEFEF\"><a hef=\"bencandy.php?fid=54&amp;id=845\" onclick=\"\" title=\"努力之中  穿插着从容与坚定\">努力之中  穿插着从容与坚定</a></td>                              </t>                                                          </table></td>                          <td width=\"13\" bgcolo=\"#FFFFFF\">&nbsp;</td>                        </t>                        <t>                          <td width=\"13\" bgcolo=\"#FFFFFF\">&nbsp;</td>                          <td width=\"756\" align=\"cente\" valign=\"middle\" bgcolo=\"#FFFFFF\"><h width=\"100%\" size=\"1\"></td>                          <td width=\"13\" bgcolo=\"#FFFFFF\">&nbsp;</td>                        </t>                        <t>                          <td width=\"13\" bgcolo=\"#FFFFFF\">&nbsp;</td>                          <td width=\"756\" align=\"left\" valign=\"top\" bgcolo=\"#FFFFFF\">				      </td>					</t>	  </table>				  <!----><DIV id=foot>  <p><b>    成都理工大学招生信息网 &copy; 成都理工大学招生办公室. </p>  <p>&nbsp;</p>  <p>All ights eseved @ 2008.<a hef=\"mailto:zs@cdut.edu.cn\" style=\"colo:#FFFFFF\">联系我们</a></p></DIV><SCIPT LANGUAGE=\"JavaScipt\"><!--//目的是为了做风格方便document.wite('</div>');//--></SCIPT><SCIPT LANGUAGE=\"JavaScipt\"><!--clickEdit.init();//--></SCIPT></cente></body></html>";
		//String reg = "<td width=\"717\" height=\"12\" align=\"center\" valign=\"middle\" bgcolor=\"#FFFFFF\" class=\"txt12a\">(.*?)</td>";
		String reg = "<td width=\"717\" height=\"12\".*?>(.*?)</td>";
		Pattern pt = Pattern.compile(reg);
		Matcher mc = pt.matcher(str);
		if (mc.find())
			System.out.println(mc.group(1));
		else 
			System.out.println("没有匹配");
			*/
		PatternTool pt = new PatternTool();
		pt.buildFrame();
	}

}
